/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.invest.action;

import br.com.invest.model.Acao;
import br.com.invest.model.Transacao;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.faces.model.SelectItem;
import org.hibernate.Session;
import org.hibernate.criterion.Order;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.datamodel.DataModel;

/**
 *
 * @author ceatis
 */
@Name("transacaoController")
@Scope(ScopeType.SESSION)
public class TransacaoController implements Serializable {

    @DataModel("acoesDM")
    private List<Acao> acoes;
    private List<SelectItem> listaAcoes;
    private Transacao transacao;
//    private Grupo grupo;
    @In
    private Session investDB;
    public String acaoSelecionada;
    public final String Transacao = "transacao";

    public String createSetup() {

        transacao = new Transacao();
        listaAcoes = new ArrayList<SelectItem>(0);
        listaAcoes.add(new SelectItem(null, "..."));
        List<Acao> la = investDB.createCriteria(Acao.class).addOrder(Order.asc("nome")).list();

        for (Acao a : la) {
            listaAcoes.add(new SelectItem(a.getNome(), a.getEmpresa().getNome()));

        }

        return Transacao;
    }

    public String comprarAcao() {



        return null;
    }

    //GETTERS E SETTERS
    //<editor-fold>
    public String getAcaoSelecionada() {
        return acaoSelecionada;
    }

    public void setAcaoSelecionada(String acaoSelecionada) {
        this.acaoSelecionada = acaoSelecionada;
    }

    public List<SelectItem> getListaAcoes() {
        return listaAcoes;
    }

    public void setListaAcoes(List<SelectItem> listaAcoes) {
        this.listaAcoes = listaAcoes;
    }
    //</editor-fold>
}
